package com.framework;

import java.time.LocalDateTime;
import java.util.UUID;

// 用户服务组件
class UserServiceComponent implements Component<UserRegistrationRequest, UserRegistrationResponse> {

    @Override
    public String getType() {
        return "UserService";
    }

    @Override
    public ComponentOutput<UserRegistrationResponse> execute(ComponentContext<UserRegistrationRequest> context) {
        // 模拟用户创建逻辑
        UserRegistrationRequest request = context.getRequestData();
        UserRegistrationResponse response = new UserRegistrationResponse();
        response.setUserId(UUID.randomUUID().toString());
        response.setCreatedAt(LocalDateTime.now());
        response.setStatus("ACTIVE");

        // 模拟延迟
        try { Thread.sleep(150); } catch (InterruptedException e) {}

        return ComponentOutput.success(response);
    }
}